package cn.acac.yygh.cmn.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;

public class ExcelReadTest {

    // 方式一：读取单个的sheet
    /*public static void main(String[] args) {
        // Excel的读取操作
        EasyExcel.read("C:\\Users\\18034\\Desktop\\hello.xlsx",Student.class,new ExcelListener())
                .sheet(0).doRead();
    }*/

    // 方式二：读取多个sheet
    public static void main(String[] args) {
        ExcelReader excelReader = EasyExcel.read("C:\\Users\\18034\\Desktop\\hello.xlsx").build();
        ReadSheet sheet01 = EasyExcel.readSheet(0)
                .head(Student.class)
                .registerReadListener(new ExcelListener())
                .build();
        ReadSheet sheet02 = EasyExcel.readSheet(1)
                .head(Student.class)
                .registerReadListener(new ExcelListener())
                .build();
        // 进行读取多个sheet操作
        excelReader.read(sheet01,sheet02);
        // 关闭流
        excelReader.finish();
    }
}
